<template>
  <div class="main">
    <!-- <h3>项目管理</h3> -->
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <span><el-row :gutter="10" class="mb8">
           <el-button
            style="float: right;"
            type="primary"
            size="mini"
            @click="addHour">补增工时</el-button>
          </el-row>
        </span>
      </div>
      <div class="text item">
        <template>


          <el-table :row-class-name="tableRowClassName"
            :data="tableData"  style="width: 100%" :default-sort="{ prop: 'userId' }">
            <el-table-column fixed type="index" label="序号" width="50" align="center" />
            <el-table-column prop="userName" label="姓名"  align="center"/>
            <el-table-column prop="postName" label="职位" align="center" />

            <el-table-column label="今日动向" align="center">
              <el-table-column prop="todayPo" label="PO号" width="120" align="center"/>
              <el-table-column prop="todayPj" label="项目名称" align="center" />
            </el-table-column>

            <el-table-column label="明日动向" align="center">
              <el-table-column prop="nextPo" label="PO号" align="center" />
              <el-table-column prop="nextPj" label="明日动向" align="center" />
            </el-table-column>

            <el-table-column prop="dangerAct" label="风险评估" align="center">
<!--              <template slot-scope="scope">-->
<!--                <p>{{ scope.row.yesFill }}/{{ scope.row.yesMustFill }}</p>-->
<!--              </template>-->
            </el-table-column>
            <el-table-column prop="managerAct" label="管理动作" align="center">
<!--              <template slot-scope="scope">-->
<!--                <p>{{ scope.row.todayFill }}/{{ scope.row.todayMustFill }}</p>-->
<!--              </template>-->
            </el-table-column>

            <el-table-column label="操作" width="110" align="center">
              <template slot-scope="scope">
                <el-button
                  @click="handleClick(scope.row)"
                  type="primary"
                  size="small"
                  plain
                >历史动向
                </el-button>
              </template>
            </el-table-column>
          </el-table>


          <pagination
            v-show="total > 0"
            :total="total"
            :page.sync="queryParams.pageNum"
            :limit.sync="queryParams.pageSize"
            @pagination="getList"
          />
        </template>
      </div>
    </el-card>
    <addForm ref="addform"></addForm>
  </div>
</template>

<script>
// import {listProject} from "@/api/project"
import {
  listProject,
  delProject,
  getDicttype,
  getProjectStatus,
  updaProjectStatus,
  personTerandList,
  projectHourStatStatus
} from "@/api/system/project";
import Moment from 'moment'
import addForm from "./addForm.vue";

export default {
  components: {
    addForm
  },

  data() {
    return {
      tableData: [],
      // 查询按钮
      statusBtns: [],
      //字典
      statusDict: new Array(),
      //总条数
      total: 0,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        todayDate: Moment(new Date()).format("YYYY-MM-DD"),
        nextDate: Moment(new Date()).add(1,'days').format("YYYY-MM-DD"),
        status: undefined
      }
    };
  },
  created() {
    this.init();
  },
  methods: {
    init() {
      personTerandList(this.queryParams).then(res => {
        console.log("personTerandList", res);
        if (res.code == 200) {
          this.total = res.total;
          this.tableData = res.rows;
          // this.tableData.forEach(el => {
          //   el.trjd = this.setPercentage(el.useHour, el.totalHour);
          //   el.status = this.judgeState(el.useHour, el.totalHour);
          // });
        } else {
          this.$message.error(res.msg);
        }
      });
    },
    tableRowClassName({row, rowIndex}) {

      if (row.dangerAct == null) {
        if (rowIndex%2==0){
          return 'info-row';
        }else {
          return ''
        }
      }
      return 'warning-row';
    },
    addHour(){
      console.log("补增工时");
      this.$refs.addform.open();
    },
    handleClick(row){},
    getList() {
      this.loading = true;
      this.init();
    },

  }
};
</script>

<style>
.el-table .warning-row {
  background: #E6A23C;
}
.el-table .info-row {
  background: #fafafa;
}


.text {
  font-size: 14px;
}

.item {
  margin-bottom: 18px;
}

.clearfix:before,
.clearfix:after {
  display: table;
  content: "";
}

.clearfix:after {
  clear: both;
}

.box-card {
  width: 100%;
}
</style>
